<template>
	<view>
		<view class="swiper" style="padding: 20rpx;background-color: #fff;">
			<u-swiper :list="swiperList" @click="to" height="500"></u-swiper>
		</view>
		<u-gap height="20" bg-color="#f7f7f7"></u-gap>
		<view class="top" style="padding: 20rpx;">
			<text style="font-size: 36rpx;font-weight: bold;" class="line">{{detail.hospitalName}}</text>
			星级：<u-rate :count="count" v-model="detail.level" style="padding: 15rpx 0;"></u-rate>
			<rich-text :nodes="detail.brief" style="color: #333;font-size: 26rpx;line-height: 1.7;"></rich-text>
		</view>
		<button class="bu" style="margin-top: 40rpx;" @click="submit">挂号预约</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				swiperList: [],
				detail: () => {},
				count: 5,
				id: 0
			};
		},
		onLoad(option) {
			this.id = option.id
			this.getSwiper(option.id)
			this.getDetail(option.id)
		},
		methods: {
			getDetail(id){
				this.$request({
					url: '/prod-api/api/hospital/hospital/' + id
				}).then(res => {
					this.detail = res.data
					uni.setNavigationBarTitle({
						title:this.detail.hospitalName
					})
				})
			},
			getSwiper(id){
				this.$request({
					url: '/prod-api/api/hospital/banner/list',
					data: {
						hospitalId: id
					}
				}).then(res => {
					console.log(res)
					this.swiperList = res.data.map(item => ({image: this.$baseUrl + item.imgUrl, id: item.id}))
				})
			},
			submit(){
				uni.navigateTo({
					url:'/pages/reserve/reserve?id=' + this.id
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
